<template>
  <div>
    <router-view></router-view>
    <NavBar v-if="state.show"></NavBar>
  </div>
</template>

<script setup>
import NavBar from '@/components/NavBar.vue'
import { reactive } from 'vue';
import { useRouter } from 'vue-router';

const state = reactive({
  menu:['/home','/data','/setting'],
  show:true
})
//是否显示导航栏取，决于当前路由是否在menu菜单中

const router = useRouter();
router.beforeEach((to, from, next) => {
  // console.log(to);
  // console.log(from);
  
  state.show = state.menu.includes(to.path);
  next();
}) 


</script>

<style lang="scss" scoped>

</style>